<%--
  Created by IntelliJ IDEA.
  User: soft01
  Date: 21-10-19
  Time: 下午12:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>评论审核</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/back-index.css" />
    <script src="${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-paginator.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-mypaginator.js"></script>

    <script type="text/javascript" >
        $(function(){
            // 显示隐藏查询列表
            $('#show-user-search').click(function() {
                $('#show-user-search').hide();
                $('#upp-user-search').show();
                $('.showusersearch').slideDown(500);
            });
            $('#upp-user-search').click(function() {
                $('#show-user-search').show();
                $('#upp-user-search').hide();
                $('.showusersearch').slideUp(500);
            });
            $("#doSearch").click(function () {
                $("#searchForm").submit();
            })
            $("input[name=yong]").click(function () {
                let status = $(this).attr("status");
                let id=$(this).attr("commentId");
                $.ajax({
                    type:"post",
                    url:"${pageContext.request.contextPath}/manage/yongManageByCommentId.do",
                    data:{
                        "status":status,
                        "commentId":id
                    },
                    dataType:"json",
                    success:function (result) {
                        if(result.responseCode=="2001"){
                            location.href="${pageContext.request.contextPath}/manage/searchManageByForm2.do?pageNo="+
                                "${sessionScope.manageCommentList.pageNum==0?1:sessionScope.manageCommentList.pageNum}";
                        }else {
                            $("#Mrg").text(result.message);
                        }
                    }
                })
            })
            //按钮的超链接设置函数
                  myoptions.pageUrl = function(type, page, current) {
                      return "${pageContext.request.contextPath}/manage/searchManageByForm2.do?pageNo="
                              + page;
                  };
            //分页回调函数,点击按钮事件
//             myoptions.onPageClicked = function(event, originalEvent, type, page) {
//                 //ajax回调接收数据成功时再重新初始化分页按钮
//                 console.log("pageNo=", page);
// //                 location.href= ".../pageNo=" + page;
//             };

            //分页,在bootstrap-mypaginator.js中
            myPaginatorFun("myPages",
                "${sessionScope.manageCommentList.pageNum==0?1:sessionScope.manageCommentList.pageNum}",
                "${sessionScope.manageCommentList.pages==0?1:sessionScope.manageCommentList.pages}");
        });
    </script>
</head>

<body>
<div class="panel panel-default" id="userSet">
    <div class="panel-heading">
        <h3 class="panel-title">评论审核<span id="Mrg" style="color: red">${sessionScope.manageNull}</span></h3>
    </div>
    <div>
        <input type="button" value="查询" class="btn btn-success" id="doSearch" style="margin: 5px 5px 5px 15px;" />
        <input type="button" class="btn btn-primary" id="show-user-search" value="展开搜索" />
        <input type="button" value="收起搜索" class="btn btn-primary" id="upp-user-search" style="display: none;" />
    </div>

    <div class="panel-body">
        <div class="showusersearch" style="display: none;">
            <form class="form-horizontal" method="post" id="searchForm" action="${pageContext.request.contextPath}/manage/searchManageByForm.do">
                <div class="form-group">
                    <div class="form-group col-xs-6">
                        <label for="user-name" class="col-xs-3 control-label">用户名：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="user-name" name="commentUserName" placeholder="请输入用户名" />
                        </div>
                    </div>
                    <div class="form-group col-xs-6">
                        <label for="user-comment" class="col-xs-3 control-label">评论内容：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="user-comment" name="context" placeholder="请输入评论内容" />
                        </div>
                    </div>
                </div>
                <!-- <div class="form-group">
                    <div class="form-group col-xs-6">
                        <label for="role-name" class="col-xs-3 control-label">状态：</label>
                        <div class="col-xs-8">
                            <select class="form-control" id="role-name" name="role-name" >
                                <option value="-1" >全部</option>
                                <option value="普通" >待审核</option>
                                <option value="管理员" >禁用</option>
                                <option value="管理员" >启用</option>
                            </select>
                        </div>
                    </div>
                </div> -->
                <div class="form-group">
                    <div class="form-group col-xs-6">
                        <label class="col-xs-3 control-label">开始日期：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" name="kaishitime" placeholder="请输入评论开始时间:2017-10-10" />
                        </div>
                    </div>
                    <div class="form-group col-xs-6">
                        <label class="col-xs-3 control-label">结束日期：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" name="jieshutime" placeholder="请输入评论结束时间:2017-10-12" />
                        </div>
                    </div>
                </div>

            </form>
        </div>

        <div class="show-list">
            <table class="table table-bordered table-hover" style='text-align: center;'>
                <thead>
                <tr class="text-danger">
                    <th class="text-center">编号</th>
                    <th class="text-center">评论内容</th>
                    <th class="text-center">用户名</th>
                    <th class="text-center">评论时间</th>
                    <th class="text-center">赞</th>
                    <th class="text-center">状态</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="tb">
                <span style="color: red" id="yongMrg"></span>
                <c:forEach items="${sessionScope.manageCommentList.list}" var="comment" varStatus="i" >
                    <tr>
                        <td>${i.index+1}</td>
                        <td>${comment.context}</td>
                        <td>${comment.user.nickname}</td>
                        <td><fmt:formatDate value="${comment.createDate}" pattern="yyyy-MM-dd hh:mm:ss"/></td>
                        <td>${comment.praiseCount==null?0:comment.praiseCount}</td>
                        <td>待审核</td>
                        <td class="text-center">
                            <input type="button" class="btn btn-success btn-sm" name="yong" commentId="${comment.id}" status="1" value="通过" />
                            <input type="button" class="btn btn-danger btn-sm" name="yong" commentId="${comment.id}" status="-1" value="禁用" />
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

        <!-- 分页 -->
        <div style="text-align: center;" >
            <ul id="myPages" ></ul>
        </div>

    </div>
</div>
</body>

</html>